package com.itheima.testswagger.controller;

import com.itheima.testswagger.pojo.Student;
import org.springframework.web.bind.annotation.*;

/**
 * <h4>xc</h4>
 * <p>swagger测试</p>
 *
 * @author : by wujianming
 * @date : 2021-12-07 09:32
 **/
@RestController
@RequestMapping("stu")
public class HelloSwagger implements SwaggerApi {
    /**
     * @return java.lang.String
     * @Description 测试无参数接口地址
     * @Date 2021/12/7 9:34
     * @Param []
     **/
    @Override
    @GetMapping("hello")
    public String hello() {
        return "无参数";
    }

    /**
     * @return java.lang.String
     * //queryString(?传参)风格的传参方式
     * @Description
     * @Date 2021/12/7 10:03
     * @Param [name]
     **/
    @Override
    @GetMapping
    public String queryString(@RequestParam("name") String name) {
        return name;
    }

    //测试path(路径)风格的传参方式
    @Override
    @GetMapping("{age}")
    public String path(@PathVariable("age") String age) {
        System.out.println("age = " + age);
        return age;
    }


    //测试json格式的传参方式
    //{

    //Student数据
    //   }
    @Override
    @PostMapping
    public Student jsonStudent(@RequestBody Student student) {
        return student;
    }

    //测试queryString . path路径以及json格式的组合传参
    @Override
    @PutMapping("{id}")
    public Student qPJStudent(@PathVariable("id") String id,
                              @RequestParam("name") String name,
                              @RequestBody Student student) {
        student.setName(name);
        student.setStuNo(id);
        return student;
    }


}
